package com.jmgd.cjlx.controller;


import com.jmgd.cjlx.service.GdjfService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.text.SimpleDateFormat;
import java.util.Date;

@RestController
@RequestMapping("/exportjf")
public class ExcelExportJFController {
    @Autowired
    GdjfService gdjfService;


    /*
    生成药监数据,批发销售出库，即系配送门店
    */
    @RequestMapping(value = "/lxExcelSaleYJ", method = RequestMethod.GET)
    public String lxExcelYJ(String beginDateStr,String endDateStr) throws Exception {
        System.out.println("生成药监批发配送开始");
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
        System.out.println("============="+beginDateStr);
        System.out.println("============="+endDateStr);
        Date beginDate = sdf.parse(beginDateStr);
        Date endDate = sdf.parse(endDateStr);
        gdjfService.createExcelSaleYJ(beginDate,endDate);
        System.out.println("生成药监批发配送xml成功");
        return "success";
    }

    @RequestMapping(value = "/lxExcelSaleReturnYJ", method = RequestMethod.GET)
    public String lxExcelSaleReturnYJ(String beginDateStr,String endDateStr) throws Exception {
        System.out.println("生成药监批发配送退货开始");
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
        System.out.println("============="+beginDateStr);
        System.out.println("============="+endDateStr);
        Date beginDate = sdf.parse(beginDateStr);
        Date endDate = sdf.parse(endDateStr);
        gdjfService.createExcelSaleReturnYJ(beginDate,endDate);
        System.out.println("生成药监批发配送退货xml成功");
        return "success";
    }

    @RequestMapping(value = "/lxExcelPurYJ", method = RequestMethod.GET)
    public String lxExcelPurYJ(String beginDateStr,String endDateStr) throws Exception {
        System.out.println("生成药监采购入库开始");
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
        System.out.println("============="+beginDateStr);
        System.out.println("============="+endDateStr);
        Date beginDate = sdf.parse(beginDateStr);
        Date endDate = sdf.parse(endDateStr);
        gdjfService.createExcelPurYJ(beginDate,endDate);
        System.out.println("生成药监采购退货xml成功");
        return "success";
    }

    @RequestMapping(value = "/lxExcelPurReturnYJ", method = RequestMethod.GET)
    public String lxExcelPurReturnYJ(String beginDateStr,String endDateStr) throws Exception {
        System.out.println("生成药监采购退货开始");
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
        System.out.println("============="+beginDateStr);
        System.out.println("============="+endDateStr);
        Date beginDate = sdf.parse(beginDateStr);
        Date endDate = sdf.parse(endDateStr);
        gdjfService.createExcelPurReturnYJ(beginDate,endDate);
        System.out.println("生成药监采购退货xml成功");
        return "success";
    }

    @RequestMapping(value = "/lxExcelStockYJ", method = RequestMethod.GET)
    public String lxExcelStockYJ(String beginDateStr,String endDateStr) throws Exception {
        System.out.println("生成药监仓库开始");
        System.out.println("============="+beginDateStr);
        System.out.println("============="+endDateStr);
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
        Date beginDate = sdf.parse(beginDateStr);
        gdjfService.createExcelStockYJ(beginDate);
        System.out.println("生成药监仓库xml生成");
        return "success";
    }

}

